package com.tamecode.chapter05.part11.sub1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ServiceConfig {

    // 把其它配置文件注入进来
    @Autowired
    private DaoConfig daoConfig;


    // 直接使用
    @Bean
    public LogonService logonService() {
        LogonService logonService = new LogonService();
        // @Bean 默认是单例，所以返回的都同一个对象。
        logonService.setLogDao(daoConfig.logDao());
        logonService.setUserDao(daoConfig.userDao());
        return logonService;
    }

}
